package com.ls.bpmn.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ls.bpmn.mapper.CategoryMapper;
import com.ls.bpmn.service.IDefinitionService;
import com.ls.bpmn.vo.ProcessDefinitionVO;
import com.ls.common.DataGridView;
import com.ls.common.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author lisheng
 * @Date 2025/04/26 22:04
 **/
@Service("definitionService")
public class DefinitionServiceImpl implements IDefinitionService {


    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public DataGridView list(PageModel pageModel, Integer categoryId) {
        Page<ProcessDefinitionVO> page = new Page<>(pageModel.getPage(), pageModel.getLimit());
        categoryId = categoryId == 0 ? null : categoryId;
        // 分类下流程定义查询
        List<ProcessDefinitionVO> list = categoryMapper.selectCategoryDefinition(page, categoryId);
        return new DataGridView(page.getTotal(), list);
    }
}